package com.alibaba.citrus.cr.common.enums.ordercenter;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author baizhuo
 * @version 1.0
 * @date 2023/8/22 14:17
 */
public enum AutoFulfillmentOrderStatusCirculationEnum {
    /*
    11:创建失败，12:创建成功
21:库存不足，22:库存不足且活动冲突
23:信贷不足，24:信贷不足且活动冲突
25:其他原因，26:其他原因且活动冲突
27:分析完全满足但活动冲突，28:完全通过
31:生成销售订单成功 32:生成销售订单失败
33:sap推送失败，34:sap推送成功
     */
    CREATE_FORECAST_ORDER_FAILED(11, "预报单创建失败"),
    CREATE_FORECAST_ORDER_SUCCEED(12, "预报单创建成功"),
    ANALYZE_FAILED(20, "分析失败"),
    STOCK_NOT_ENOUGH(21, "库存不足"),
    STOCK_NOT_ENOUGH_AND_ACTIVITY_CONFLICT(22, "库存不足且活动冲突"),
    CREDIT_NOT_ENOUGH(23, "信贷不足"),
    CREDIT_NOT_ENOUGH_AND_ACTIVITY_CONFLICT(24, "信贷不足且活动冲突"),
    OTHER_REASON(25, "其他原因"),
    OTHER_REASON_AND_ACTIVITY_CONFLICT(26, "其他原因且活动冲突"),
    ACTIVITY_CONFLICT(27, "分析完全满足但活动冲突"),
    ALL_PASS(28, "完全通过"),
    CREATE_SALE_ORDER_SUCCEED(31, "生成销售订单成功"),
    CREATE_SALE_ORDER_FAILED(32, "生成销售订单失败"),
    PUSH_TO_SAP_FAILED(33, "sap推送失败"),
    PUSH_TO_SAP_SUCCEED(34, "sap推送成功"),

    ;

    private int code;
    private String desc;

    AutoFulfillmentOrderStatusCirculationEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static AutoFulfillmentOrderStatusCirculationEnum of(int code) {
        return Arrays.stream(AutoFulfillmentOrderStatusCirculationEnum.values()).filter(source -> source.code == code).findFirst().orElse(null);
    }

}
